<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>FastAPI 接口文档</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            line-height: 1.6;
            margin: 0;
            padding: 20px;
            color: #333;
        }
        h1 {
            color: #2c3e50;
            border-bottom: 2px solid #3498db;
            padding-bottom: 10px;
        }
        .endpoint {
            background: #f9f9f9;
            border-left: 4px solid #3498db;
            padding: 15px;
            margin-bottom: 20px;
            border-radius: 0 5px 5px 0;
        }
        .method {
            font-weight: bold;
            color: #3498db;
        }
        .path {
            font-family: monospace;
            background: #eee;
            padding: 2px 5px;
            border-radius: 3px;
        }
        table {
            width: 100%;
            border-collapse: collapse;
            margin: 15px 0;
        }
        th, td {
            border: 1px solid #ddd;
            padding: 8px;
            text-align: left;
        }
        th {
            background-color: #f2f2f2;
        }
        .example {
            background: #f5f5f5;
            padding: 10px;
            border-radius: 5px;
            font-family: monospace;
            white-space: pre-wrap;
            margin: 10px 0;
        }
    </style>
</head>
<body>
    <h1>FastAPI 接口文档</h1>
    
    <!-- 用户相关接口 -->
    <div class="endpoint">
        <h2>用户接口</h2>
        
        <!-- 创建用户 -->
        <div>
            <h3><span class="method">POST</span> <span class="path">/users/</span></h3>
            <p>插入用户的API接口</p>
            
            <h4>请求参数</h4>
            <table>
                <tr>
                    <th>参数名</th>
                    <th>位置</th>
                    <th>是否必须</th>
                    <th>类型</th>
                    <th>描述</th>
                </tr>
                <tr>
                    <td>username</td>
                    <td>query</td>
                    <td>是</td>
                    <td>string</td>
                    <td>用户名</td>
                </tr>
                <tr>
                    <td>email</td>
                    <td>query</td>
                    <td>是</td>
                    <td>string</td>
                    <td>邮箱</td>
                </tr>
                <tr>
                    <td>password</td>
                    <td>query</td>
                    <td>是</td>
                    <td>string</td>
                    <td>密码</td>
                </tr>
            </table>
            
            <h4>响应</h4>
            <p>200: 成功响应</p>
            <p>422: 验证错误</p>
            
            <h4>示例</h4>
            <div class="example">
POST /users/?username=testuser&email=test@example.com&password=123456 HTTP/1.1
Host: example.com
            </div>
        </div>
        
        <!-- 获取所有用户 -->
        <div>
            <h3><span class="method">GET</span> <span class="path">/users/</span></h3>
            <p>获取全部用户的API接口</p>
            
            <h4>响应</h4>
            <p>200: 成功响应</p>
            
            <h4>示例</h4>
            <div class="example">
GET /users/ HTTP/1.1
Host: example.com
            </div>
        </div>
        
        <!-- 获取单个用户 -->
        <div>
            <h3><span class="method">GET</span> <span class="path">/users/{user_id}</span></h3>
            <p>通过用户ID获取用户的API接口</p>
            
            <h4>请求参数</h4>
            <table>
                <tr>
                    <th>参数名</th>
                    <th>位置</th>
                    <th>是否必须</th>
                    <th>类型</th>
                    <th>描述</th>
                </tr>
                <tr>
                    <td>user_id</td>
                    <td>path</td>
                    <td>是</td>
                    <td>integer</td>
                    <td>用户ID</td>
                </tr>
            </table>
            
            <h4>响应</h4>
            <p>200: 成功响应</p>
            <p>422: 验证错误</p>
            
            <h4>示例</h4>
            <div class="example">
GET /users/123 HTTP/1.1
Host: example.com
            </div>
        </div>
    </div>
    
    <!-- 文章相关接口 -->
    <div class="endpoint">
        <h2>文章接口</h2>
        
        <!-- 创建文章 -->
        <div>
            <h3><span class="method">POST</span> <span class="path">/articles/</span></h3>
            <p>创建文章API</p>
            
            <h4>请求参数</h4>
            <table>
                <tr>
                    <th>参数名</th>
                    <th>位置</th>
                    <th>是否必须</th>
                    <th>类型</th>
                    <th>描述</th>
                </tr>
                <tr>
                    <td>title</td>
                    <td>query</td>
                    <td>是</td>
                    <td>string</td>
                    <td>标题</td>
                </tr>
                <tr>
                    <td>content</td>
                    <td>query</td>
                    <td>是</td>
                    <td>string</td>
                    <td>内容</td>
                </tr>
            </table>
            
            <h4>响应</h4>
            <p>200: 成功响应</p>
            <p>422: 验证错误</p>
            
            <h4>示例</h4>
            <div class="example">
POST /articles/?title=测试文章&content=这是文章内容 HTTP/1.1
Host: example.com
            </div>
        </div>
        
        <!-- 获取所有文章 -->
        <div>
            <h3><span class="method">GET</span> <span class="path">/articles/</span></h3>
            <p>获取所有文章API</p>
            
            <h4>响应</h4>
            <p>200: 成功响应</p>
            
            <h4>示例</h4>
            <div class="example">
GET /articles/ HTTP/1.1
Host: example.com
            </div>
        </div>
        
        <!-- 获取单个文章 -->
        <div>
            <h3><span class="method">GET</span> <span class="path">/articles/{article_id}</span></h3>
            <p>获取文章详情API</p>
            
            <h4>请求参数</h4>
            <table>
                <tr>
                    <th>参数名</th>
                    <th>位置</th>
                    <th>是否必须</th>
                    <th>类型</th>
                    <th>描述</th>
                </tr>
                <tr>
                    <td>article_id</td>
                    <td>path</td>
                    <td>是</td>
                    <td>integer</td>
                    <td>文章ID</td>
                </tr>
            </table>
            
            <h4>响应</h4>
            <p>200: 成功响应</p>
            <p>422: 验证错误</p>
            
            <h4>示例</h4>
            <div class="example">
GET /articles/456 HTTP/1.1
Host: example.com
            </div>
        </div>
        
        <!-- 更新文章 -->
        <div>
            <h3><span class="method">PUT</span> <span class="path">/articles/{article_id}</span></h3>
            <p>更新文章API</p>
            
            <h4>请求参数</h4>
            <table>
                <tr>
                    <th>参数名</th>
                    <th>位置</th>
                    <th>是否必须</th>
                    <th>类型</th>
                    <th>描述</th>
                </tr>
                <tr>
                    <td>article_id</td>
                    <td>path</td>
                    <td>是</td>
                    <td>integer</td>
                    <td>文章ID</td>
                </tr>
                <tr>
                    <td>title</td>
                    <td>query</td>
                    <td>是</td>
                    <td>string</td>
                    <td>标题</td>
                </tr>
                <tr>
                    <td>content</td>
                    <td>query</td>
                    <td>是</td>
                    <td>string</td>
                    <td>内容</td>
                </tr>
            </table>
            
            <h4>响应</h4>
            <p>200: 成功响应</p>
            <p>422: 验证错误</p>
            
            <h4>示例</h4>
            <div class="example">
PUT /articles/456?title=更新后的标题&content=更新后的内容 HTTP/1.1
Host: example.com
            </div>
        </div>
        
        <!-- 删除文章 -->
        <div>
            <h3><span class="method">DELETE</span> <span class="path">/articles/{article_id}</span></h3>
            <p>删除文章API</p>
            
            <h4>请求参数</h4>
            <table>
                <tr>
                    <th>参数名</th>
                    <th>位置</th>
                    <th>是否必须</th>
                    <th>类型</th>
                    <th>描述</th>
                </tr>
                <tr>
                    <td>article_id</td>
                    <td>path</td>
                    <td>是</td>
                    <td>integer</td>
                    <td>文章ID</td>
                </tr>
            </table>
            
            <h4>响应</h4>
            <p>200: 成功响应</p>
            <p>422: 验证错误</p>
            
            <h4>示例</h4>
            <div class="example">
DELETE /articles/456 HTTP/1.1
Host: example.com
            </div>
        </div>
    </div>
    
    <!-- 其他接口 -->
    <div class="endpoint">
        <h2>其他接口</h2>
        
        <!-- 根路径 -->
        <div>
            <h3><span class="method">GET</span> <span class="path">/</span></h3>
            <p>Hello</p>
            
            <h4>响应</h4>
            <p>200: 成功响应</p>
            
            <h4>示例</h4>
            <div class="example">
GET / HTTP/1.1
Host: example.com
            </div>
        </div>
        
        <!-- 打招呼 -->
        <div>
            <h3><span class="method">GET</span> <span class="path">/hello/{name}</span></h3>
            <p>Say Hello</p>
            
            <h4>请求参数</h4>
            <table>
                <tr>
                    <th>参数名</th>
                    <th>位置</th>
                    <th>是否必须</th>
                    <th>类型</th>
                    <th>描述</th>
                </tr>
                <tr>
                    <td>name</td>
                    <td>path</td>
                    <td>是</td>
                    <td>string</td>
                    <td>名称</td>
                </tr>
            </table>
            
            <h4>响应</h4>
            <p>200: 成功响应</p>
            <p>422: 验证错误</p>
            
            <h4>示例</h4>
            <div class="example">
GET /hello/world HTTP/1.1
Host: example.com
            </div>
        </div>
        
        <!-- 文件上传 -->
        <div>
            <h3><span class="method">POST</span> <span class="path">/upload/</span></h3>
            <p>Upload File</p>
            
            <h4>请求体</h4>
            <table>
                <tr>
                    <th>参数名</th>
                    <th>类型</th>
                    <th>是否必须</th>
                    <th>描述</th>
                </tr>
                <tr>
                    <td>file</td>
                    <td>binary</td>
                    <td>是</td>
                    <td>文件</td>
                </tr>
            </table>
            
            <h4>响应</h4>
            <p>200: 成功响应</p>
            <p>422: 验证错误</p>
            
            <h4>示例</h4>
            <div class="example">
POST /upload/ HTTP/1.1
Host: example.com
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW

------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="file"; filename="example.txt"
Content-Type: text/plain

(文件内容)
------WebKitFormBoundary7MA4YWxkTrZu0gW--
            </div>
        </div>
    </div>
</body>
</html>